package sleuthkit.gui.actionlistener;

import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;

import org.apache.log4j.Logger;

import sleuthkit.gui.MainApplication;
import sleuthkit.util.CaseManagement;

public class GoToMainProcessingWindowActionListener implements ActionListener {

	private MainApplication mainApplication;
	private JPanel cardPanel;
	private Logger log = Logger
			.getLogger(GoToMainProcessingWindowActionListener.class);
	private JTree explorerViewJTree;
	private CaseManagement cm;
	private JScrollPane explorerViewJTreeJScrollPane;

	public GoToMainProcessingWindowActionListener(
			MainApplication mainApplication, JPanel cardPanel) {
		this.mainApplication = mainApplication;
		this.cardPanel = cardPanel;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		explorerViewJTree = mainApplication.getExplorerViewJTree();
		explorerViewJTreeJScrollPane = mainApplication.getExplorerViewJTreeJScrollPane();
		
		log.debug("Size of explorerViewJTree " + explorerViewJTree.getSize());
		explorerViewJTree.setMinimumSize(new Dimension(80, 228));
		log.debug("Size of explorerViewJTree " + explorerViewJTree.getSize());
		explorerViewJTreeJScrollPane.setMinimumSize(new Dimension(80, 228));

		log.debug("showing layout for "
				+ mainApplication.getNameOfPane(mainApplication
						.getMainProcessingWindow()));
		((CardLayout) cardPanel.getLayout()).show(cardPanel, mainApplication
				.getNameOfPane(mainApplication.getMainProcessingWindow()));

		cm = CaseManagement.getInstance();

		cm.populateTree(explorerViewJTree);
	}

}
